const app = getApp()
// const user = wx.getStorageSync("user");
var user_token = wx.getStorageSync('user_token');
const base_url = app.globalData.base_url;
var carwx = '';
var id = 0;
const util = require('../../utils/util.js');
Page({
  /**
    * 页面的初始数据
    */
  data: {
    carinfo: {},
    carphone: 0,
  },
  onLoad: function (options) {
    var that = this;
    id = decodeURIComponent(options.id);

    wx.request({
      url: base_url + '/Public/getCarInfo',
      method: 'POST',
      data: {
        'id': id
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log(res)
        if (res.data.success == '1') {

          var nick_name = ''
          if (res.data.data.real_name == '') {
            nick_name = res.data.data.wx_nick_name;
          } else {
            nick_name = res.data.data.real_name;
          }

          res.data.data.wx_nick_name = nick_name;

          this.setData({
            carinfo: res.data.data,
            carwx: res.data.data.wx_number
          })
          carwx = res.data.data.wx_number
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 2000
          }),
            wx.navigateBack({
              delta: 1
            })
        }
      }
    })
  },
  copyWx: function (event) {
    wx.setClipboardData({
      data: carwx,
      success: function (res) {
        wx.showToast({
          title: '已复制到剪贴板',
          icon: 'none',
          duration: 2000
        })
      }
    })
  },
})
